package soft863.com.mr3;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class mv_rate {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        //通过job对象对map类和reducer类进行封装
        Job job  = Job.getInstance(new Configuration());

        // 指定程序入口
        job.setJarByClass(mv_rate.class);

        //指定Mapper类
        job.setMapperClass(mvMapper.class);
        //指定map输出key的类型
        job.setMapOutputKeyClass(Text.class);
        //指定map输出的value类型
        job.setMapOutputValueClass(LongWritable.class);


        // 指定Reducer类
        job.setReducerClass(mvReducer.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(LongWritable.class);

        //指定要处理的数据
        FileInputFormat.setInputPaths(job,new Path("D:\\APP\\java\\AAA\\bigData\\mr\\input\\movie.txt"));
        // 指定处理后的结果保存的目录
        FileOutputFormat.setOutputPath(job,new Path("output\\data1"));
        // 等待mapreduce处理结束
        boolean boo = job.waitForCompletion(true);
        System.exit(boo?0:1);
    }
}
